
<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/head.ftl">
    <style>
        #ContentModal img{
            width: 100%;
        }
        #ContentModal .modal-body{
            overflow-x: auto;
            max-height: 500px;
        }
    </style>


    <script>
        $(function () {


            $(".inputBtn").click(function () {

                $("#strategyCatalogModal").clearForm(true);
                var json = $(this).data("json");
                console.log(json);
                if(json){
                    $("#strategyCatalogId").val(json.id);
                    $("#name").val(json.name);
                    $("#sequence").val(json.sequence);
                    $("#strategies").val(json.strategyId);
                    $("#state").val(json.state+"");
                }


                $("#strategyCatalogModal").modal("show");

            })

            $("#saveBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    if(data.success){
                        location.reload();
                    }else{
                        $.messager.alert("温馨提示",data.msg);
                    }
                })
            })


        })
    </script>


</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#--设置当前要回显当前菜单,必须在载人菜单前完成设置-->
            <#assign menu = "strategyCatalog"/>
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">攻略管理</h1>
                </div>
            </div>
            <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/strategyCatalog/list.do" method="post">
                <input type="hidden" id="currentPage" name="currentPage" value="1">
                <div class="form-group">
                    <label>攻略搜索:</label>
                    <select class="form-control" name="strategyId">
                    <option value="-1">请选择</option>
                        <#list strategies as s>
                            <option value="${s.id}">${s.title}</option>
                        </#list>
                    </select>
                    <script>
                        $("select[name=strategyId]").val(${qo.strategyId!})
                    </script>
                </div>
                <button id="btn_query" class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>

                <a role="button" class="btn btn-success inputBtn">
                    <span class="glyphicon glyphicon-plus"></span> 添加攻略分类
                </a>
            </form>

            <table class="table table-striped table-hover" >
                <tr>
                <tr>
                    <th>分类名称</th>
                    <th>所属攻略</th>
                    <th>排序</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>

                </tr>

                <#list pageInfo.list as s>
                <#--遍历查询得到的每一个domain对象-->
                    <tr>
                        <td>${s.name!}</td>
                        <td>${(s.strategy.title)!}</td>
                        <td>${s.sequence!}</td>
                        <td>${s.stateDisplay!}</td>
                        <td>
                            <a role="button" class="inputBtn" data-json='${s.json}'>修改</a>
                        </td>
                    </tr>
                </#list>

            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>


<div id="strategyCatalogModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form id="editForm" class="form-horizontal" method="post" action="/strategyCatalog/saveOrUpdate.do" style="margin: -3px 118px">
                    <input id="strategyCatalogId" type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">分类名称</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="name" name="name" placeholder="分类名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">所属攻略</label>
                        <div class="col-sm-6">
                            <select id="strategies" class="form-control" autocomplete="off" name="strategy.id"  data-placeholder="请选择所属攻略">
                                  <#list strategies as s>
                                      <option value="${s.id}">${s.title}</option>
                                  </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">排序</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sequence" name="sequence" placeholder="排序">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label">状态</label>
                        <div class="col-sm-6">
                            <select id="state" class="form-control" autocomplete="off" name="state">
                                <option value="true">启用</option>
                                <option value="false">禁用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-success" id="saveBtn" aria-hidden="true">保存</a>
                <a href="javascript:void(0);" class="btn" data-dismiss="modal" aria-hidden="true">关闭</a>
            </div>
        </div>
    </div>
</div>


</body>
</html>